package com.jacken.mars.controller;

import com.jacken.mars.entity.base.AbstractBasicController;
import com.jacken.mars.entity.base.Authentication;
import com.jacken.mars.entity.base.SecurityContextHolder;
import lombok.extern.slf4j.Slf4j;

/**
 * 基础controller
 *
 * @author 江勇
 * @date 2019/12/6
 **/
@Slf4j
public class BasicController extends AbstractBasicController {

    @Override
    public Integer getUserId() {
        Authentication authentication = SecurityContextHolder.getContext();
        if (authentication == null) {
            log.warn("the userId is not exist");
            return null;
        }
        return authentication.getUserId();
    }

}
